package com.univ3rse.maumau;

import gameObjects.CardTable;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;

public class MauMau implements ApplicationListener {
	private OrthographicCamera camera;
	private SpriteBatch batch;
	private Texture texture;
	private Sprite sprite;
	TextureRegion region;
	private Stage stage;
	CardTable table;

	@Override
	public void create() {
		float w = Gdx.graphics.getWidth();
		float h = Gdx.graphics.getHeight();
		stage = new Stage(480, 800, true);
		camera = new OrthographicCamera(480, 800);
		camera.position.set(480 / 2, 800 / 2, 0);
		camera.update();

		batch = new SpriteBatch();
		table = new CardTable(batch);
		table.setCamera(camera);

		Gdx.input.setInputProcessor(table);
		table.startGame(1);
	}

	@Override
	public void dispose() {
		batch.dispose();
		table.dispose();
	}

	@Override
	public void render() {
		Gdx.gl.glClearColor(0, 1, 1, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//		table.reCalculate();
		batch.setProjectionMatrix(camera.combined);
		// for (int i = 0; i < 4; i++) {
		// for (int j = 0; j < 8; j++) {
		batch.begin();
		// cardArray[1][0].draw(batch);
		table.act(Gdx.graphics.getDeltaTime());
		// sprite.draw(batch);
		// System.out.println("rendering card: " + i+" "+j);

		batch.end();
		if(Gdx.input.isKeyPressed(Keys.B)){
			
			table.playIt();
			
		}
		// try {
		// Thread.sleep(2000);
		// } catch (InterruptedException e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
		// }
		// }
	}

	@Override
	public void resize(int width, int height) {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

}
